//
//  MALocationManager.m
//  BP_NewClient
//
//  Created by letv on 15/7/16.
//  Copyright (c) 2015年 normal. All rights reserved.
//  高德地图定位

#import "MALocationManager.h"
#import "BPLocationViewController.h"
#import "BPSearchMapViewController.h"

@interface MALocationManager(){
    @private BPLocationViewController       *locationViewController;
    @private BPSearchMapViewController      *searchViewController;
}

// 定位vc
@property (nonatomic, strong) BPLocationViewController *locationViewController;
@property (nonatomic, strong) BPSearchMapViewController *searchViewController;

@end

@implementation MALocationManager
@synthesize locationViewController = _locationViewController;
@synthesize searchViewController = _searchViewController;

+ (MALocationManager *)shareManager
{
    static dispatch_once_t pred = 0;
    static id _instance_Obj = nil;
    
    dispatch_once(&pred, ^(){
        _instance_Obj = [[MALocationManager alloc] init];
    });
    return _instance_Obj;
}

// 定位
- (void)MALocationRequest:(MALocationSuccessBlock)locationBlock errorLocation:(MALocationErrorBlock)errorBlock{
    
    if (!_locationViewController) {
        _locationViewController = [[BPLocationViewController alloc] init];
    }

    // Request
    [_locationViewController startLocation:^(AMapAddressComponent *regeoAnnotation){

        locationBlock(regeoAnnotation);
        
    } errorBlock:^(NSDictionary *errDic){
        
        errorBlock(errDic);
    }];
}

// 地图路线搜索
- (void)MASearchPath:(BPRootViewController *)target{
    
    if (!_searchViewController) {
        _searchViewController = [[BPSearchMapViewController alloc] init];
    }
    [target.navigationController pushViewController:_searchViewController animated:YES];
}


@end
